package com.example.hilt.activity

import android.os.Bundle
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import com.example.hilt.R
import com.example.hilt.data.viewmodel.MyViewModel
import com.example.hilt.entity.Truck
import dagger.hilt.android.AndroidEntryPoint
import okhttp3.OkHttpClient
import retrofit2.Retrofit
import javax.inject.Inject

/*
    https://developer.android.google.cn/training/dependency-injection/hilt-android?hl=zh-cn#groovy

    https://mp.weixin.qq.com/s/OEX1d2cU1zGG5BBM-nANBg

     https://blog.csdn.net/guangdeshishe/article/details/122673455

    ApplicationComponent 在 Dagger 2.30版本中已经标记过时了
    ApplicationComponent 在 Dagger 2.31版本中就已经被移除了

    使用SingletonComponent代替ApplicationComponent

    viewModels()方法找不到
    https://blog.csdn.net/Myfittinglife/article/details/114029255
 */

@AndroidEntryPoint
class MainActivity : AppCompatActivity() {

    @Inject
    lateinit var truck: Truck

    @Inject
    lateinit var okHttpClient: OkHttpClient

    @Inject
    lateinit var retrofit: Retrofit

    private val viewModel: MyViewModel by viewModels()


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        truck.deliver()
    }
}